package com.ruoyi.project.remake.controller;

import java.util.List;

import com.ruoyi.project.remake.domain.constant.InitConstant;
import com.ruoyi.project.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.remake.domain.TApplyStatus;
import com.ruoyi.project.remake.service.ITApplyStatusService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 病例申请打印Controller
 *
 * @author 孙山伟
 * @date 2020-12-26
 */
@RestController
@RequestMapping("/remake/printstatus")
public class TApplyStatusController extends BaseController
{
    @Autowired
    private ITApplyStatusService tApplyStatusService;
    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询病例申请打印列表
     */
    @PreAuthorize("@ss.hasPermi('remake:printstatus:list')")
    @GetMapping("/list")
    public TableDataInfo list(TApplyStatus tApplyStatus)
    {
        startPage();
        List<TApplyStatus> list = tApplyStatusService.selectTApplyStatusList(tApplyStatus);
        return getDataTable(list);
    }

    /**
     * 导出病例申请打印列表
     */
    @PreAuthorize("@ss.hasPermi('remake:printstatus:export')")
    @Log(title = "病例申请打印", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TApplyStatus tApplyStatus)
    {
        List<TApplyStatus> list = tApplyStatusService.selectTApplyStatusList(tApplyStatus);
        ExcelUtil<TApplyStatus> util = new ExcelUtil<TApplyStatus>(TApplyStatus.class);
        return util.exportExcel(list, "printstatus");
    }

    /**
     * 获取病例申请打印详细信息
     */
    @PreAuthorize("@ss.hasPermi('remake:printstatus:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tApplyStatusService.selectTApplyStatusById(id));
    }

    /**
     * 新增病例申请打印
     */
    @PreAuthorize("@ss.hasPermi('remake:printstatus:add')")
    @Log(title = "病例申请打印", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TApplyStatus tApplyStatus)
    {
        return toAjax(tApplyStatusService.insertTApplyStatus(tApplyStatus));
    }

    /**
     * 修改病例申请打印
     */
    @PreAuthorize("@ss.hasPermi('remake:printstatus:edit')")
    @Log(title = "病例申请打印", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TApplyStatus tApplyStatus)
    {
        return toAjax(tApplyStatusService.updateTApplyStatus(tApplyStatus));
    }

    /**
     * 删除病例申请打印
     */
    @PreAuthorize("@ss.hasPermi('remake:printstatus:remove')")
    @Log(title = "病例申请打印", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tApplyStatusService.deleteTApplyStatusByIds(ids));
    }

    /**
     * 获取可以分配打印的人员信息
     */
    @GetMapping(value = "/getUserList")
    public AjaxResult getUserList()
    {
        return AjaxResult.success(sysUserService.selectUserListByRoleKey(InitConstant.PRINT_ROLE_KEY, null));
    }
}
